<template>
  <div class="common-video" v-if="isVideo">
    <div class="video-title">
      <span class="name">{{name}}</span>
      <div class="right-box">
        <span class="status" :style="{color:color().color,'background-color':color().bgcolor}">{{status}}</span>
        <img src="@/assets/img/water/shut.png" alt="" @click="closeVideo">
      </div>
    </div>
    <div class="video-content">
      <videoBox :url="videoLink"></videoBox>
    </div>
  </div>
</template>

<script>
// TODO:视频
import videoBox from './VideoBox.vue';
export default {
  data() {
    return {
    };
  },

  components: {
    videoBox
  },

  computed: {
    color() {
      return function() {
        const info = {};
        switch (this.status) {
          case '正常':
            info.color = '#57FFAA';
            info.bgcolor = '#19504e';
            break;
          case '异常':
            info.color = '#ef303b';
            info.bgcolor = '#3f1e32';
            break;
          case '停止':
            info.color = '#ADADAD';
            info.bgcolor = '#303d50';
            break;
        }
        return info;
      };
    },
    isVideo() {
      return this.$store.state.videoInfo.isVideo;
    },
    name() {
      return this.$store.state.videoInfo.name;
    },
    status() {
      return this.$store.state.videoInfo.status;
    },
    videoLink() {
      return this.$store.state.videoInfo.videoLink;
    }
  },

  methods: {
    openVideo() {
      this.$emit('openVideo');
    },
    closeVideo() {
      // 视频关闭时,重置视频选中状态
      this.$store.commit('setData', { name: 'coalFlowVideoTitle', value: null });
      this.$store.commit('setData', { name: 'ePointMonitor', value: { current: '', activeTitle: '' }});
      this.$store.commit('setData', { name: 'videoInfo', value: {
        isVideo: false,
        name: '',
        status: '',
        videoLink: ''
      }});
    }
  }
};

</script>
<style scoped lang="scss">
.common-video{
  width: 40rem;
  height: 25.5625rem;
  background-color: #041730;
  position: relative;
  top: 50%;
  left: 50%;
  transform: translate(-50%,-75%);
  .video-title{
    width: 100%;
    height: 1.875rem;
    padding-left: .625rem;
    padding-right: .9375rem;
    background-image: url('@/assets/img/water/video-title-bg.png');
    background-size: 100% 100%;
    background-repeat: no-repeat;
    display: flex;
    justify-content: space-between;
    align-items: center;
    .name{
      font-size: 1rem;
      color: #ffffff;
    }
    .right-box{
      .status{
        padding: 0 .3125rem;
        font-size: .75rem;
        line-height: 2.5rem;
        margin-right: .9375rem;
      }
      img{
        width: 1.25rem;
        height: 1.25rem;
        vertical-align: middle;
      }
      &:hover{
        cursor: pointer;
      }
    }
  }
  .video-content{
    height: 21.1875rem;
  }
}
</style>
